import Vue from 'vue'
import Vuex from 'vuex'
import actions from '../actions/team'
import {
  UPDATE_ACCOUNT_TEAM_QUERY_DATA,
  UPDATE_FOLLOW_RECORD_ANALYZE_QUERY_DATA,
  UPDATE_WEEK_FOLLOW_RECORD_ANALYZE_QUERY_DATA,
  UPDATE_ANALYZE_QUERY_DATA,
  UPDATE_YU_YUE_QUERY_DATA,
  UPDATE_CLUE_TYPE_COUNT_QUERY_DATA,
  UPDATE_CUSTOM_ORDER_ANALYZE_QUERY_DATA
} from '../mutation-types'
const localStorage = require('store')

Vue.use(Vuex)

const state = {
  'account_team_query_data': {
    createTime: [],
    type: 'mobile_num',
    typeNumber: '',
    counselorList: [],
    team_id: '',
    sourceList: [],
    channelList: [],
    customsStatusList: [],
    page_index: 1
  },
  'follow_record_query_data': {
    date: new Date(),
    team_id: '',
    source_ids: [],
    channel_ids: []
  },
  'week_follow_record_query_data': {
    date: new Date(),
    team_id: '',
    source_ids: [],
    channel_ids: []
  },
  'analyze_query_data': {
    date: new Date(),
    team_id: '',
    source_ids: [],
    channel_ids: []
  },
  'yu_yue_query_data': {
    insert_time: [],
    mobile_num: '',
    suid: [],
    team_id: '',
    page_index: 1
  },
  'clue_type_count_query_data': {
    source_id: '',
    team_id: '',
    month: new Date()
  },
  'custom_order_analyze_query_data': {
    source_id: '',
    team_id: ''
  }
}

const mutations = {
  [UPDATE_ACCOUNT_TEAM_QUERY_DATA] (state, data) {
    // console.log('UPDATE_ACCOUNT_TEAM_QUERY_DATA', JSON.stringify(data))
    state['account_team_query_data'] = data
  },
  [UPDATE_FOLLOW_RECORD_ANALYZE_QUERY_DATA] (state, data) {
    // console.log('UPDATE_FOLLOW_RECORD_ANALYZE_QUERY_DATA', JSON.stringify(data))
    state['follow_record_query_data'] = data
  },
  [UPDATE_WEEK_FOLLOW_RECORD_ANALYZE_QUERY_DATA] (state, data) {
    // console.log('UPDATE_WEEK_FOLLOW_RECORD_ANALYZE_QUERY_DATA', JSON.stringify(data))
    state['week_follow_record_query_data'] = data
  },
  [UPDATE_ANALYZE_QUERY_DATA] (state, data) {
    // console.log('UPDATE_WEEK_FOLLOW_RECORD_ANALYZE_QUERY_DATA', JSON.stringify(data))
    state['analyze_query_data'] = data
  },
  [UPDATE_YU_YUE_QUERY_DATA] (state, data) {
    state['yu_yue_query_data'] = data
  },
  [UPDATE_CLUE_TYPE_COUNT_QUERY_DATA] (state, data) {
    state['clue_type_count_query_data'] = data
  },
  [UPDATE_CUSTOM_ORDER_ANALYZE_QUERY_DATA] (state, data) {
    state['custom_order_analyze_query_data'] = data
  }
}

export default {
  state,
  mutations,
  actions
}
